#ifndef __FLYWEIGHT_H__
#define __FLYWEIGHT_H__
#include<iostream>
#include<string>
#include<unordered_map>

enum Color{
    White,
    Black,
};

struct Position{
int m_x;
int m_y;
Position(int x,int y):m_x(x),m_y(y){}
};

class Piece{
public:
    virtual ~Piece(){}
    virtual void draw(const Position& positon) = 0;
};

class WhitePiece : public Piece{
public:
    virtual void draw(const Position& positon);
};

class BlackPiece : public Piece{
public:
    virtual void draw(const Position& positon);
};


class PieceFactory{
private:
    std::unordered_map<Color,Piece*> m_pieces;

public:
    ~PieceFactory(){
        for(auto it = m_pieces.begin();it!=m_pieces.end();it++)
        {
            if(it->second)
                delete it->second;
        }
        m_pieces.clear();
    }

    Piece* getPiece(Color color);
};


#endif